# _*_ coding:utf-8 _*_

# 1.a_list = [1,2,3,2,2]
#    删除a_list中所有的2
import random
a_list = [1, 2, 3, 2, 2]
new_list = []
for i in a_list:
    if i != 2:
        new_list.append(i)

print(new_list)

# 2.用内置函数compile创建一个文件xx.py, 在文件里写你的名字, 然后用eval
# 函数读取文件中内容, 并打印输出到控制台

# with open('xx.py','r') as file:
#     file_str=file.read()
#     c = compile(file_str, '', 'eval')
#     eval(c)

# 3.写一个猜数字的游戏, 给5次机会, 每次随机生成一个整数, 然后由控制台输入一个
# 数字, 比较大小.大了提示猜大了, 小了提示猜小了.猜对了提示恭喜你, 猜对了.
# 退出程序, 如果猜错了, 一共给5次机会, 5
# 次机会用完程序退出.

from random import randint
from collections import deque
N = randint(0,100)
history = deque([],5)
# def guess(k):
#    if k==N:
#        print('right')
#        return True
#    if k < N:
#        print('%s is less -than N'%k)
#    else:
#        print('%s is greater-than N'%k)
#    return False
# while True:
#     line = input('please input a number:')
#     if line.isdigit():
#         k = int(line)
#         history.append(k)
#         if guess(k):
#             break
#         elif line=='history' or line=='h?':
#             print(list(history))
import pickle
print(pickle.dump)
#guess_number()

from random import randint,sample
# 对字典中value进行排序
a_dict={x:randint(60,100) for x in 'xyzabc'}
print(a_dict)
#print(sorted(a_dict),a_dict.keys(),a_dict.values())
#tup=zip(a_dict.values(),a_dict.keys())
#print(list(a_dict.items()))
#print(sorted(a_dict.items(),key=lambda x: x[1]))
#print(sample('abcdefg',randint(3,6)))

def guess_number():
    times = 0

    num_random = random.randint(0, 100)

    num_random = random.randint(0, 10)

    while times<5:
        num_str = input('第%d次猜数字:' % (times + 1))
        if num_str.isdigit():
            num = int(num_str)


s1 = {x : randint(1,4) for x in sample('abcdefg',randint(3,6))}
s2 = {x : randint(1,4) for x in sample('abcdefg',randint(3,6))}

s3 = {x : randint(1,4) for x in sample('abcdefg',randint(3,6))}
res = []
print(s1,s2,s3)
for k in s1:
    if k in s2 and k in s3:
        res.append(k)


#print(res)
from functools import reduce
a=set(s1.keys()) & set(s2.keys()) & s3.keys()
#m1 = map(dict.keys(),[s1,s2,s3])


from collections import OrderedDict

d= OrderedDict()
#for k in d: print(k)

player = list('ABCDEFGH')
print(player)
import time
start = time.time()

for i in range(8):
    p = player.pop(randint(0,7-i))
    end=time.time()
    print((i+1),p,end-start)
    d[p] = (i+1,end-start)

print()
print('_'*20)
for k in d:
    print(k ,d[k])
q = deque([],5)




from urllib import request


f=request.urlopen("http://wthrcdn.etouch.cn/weather_mini?city=%E5%8C%97%E4%BA%AC")

#print(f.read())

def mySplit(s,ds):
    res = [s]
    for d in ds:
        t = []
        map(lambda x: t.extend(x.split(d)),res)
        res = t
        return res

ss = 'ab;cd|efg:mn.opq;rst,uvw.xyz'
a1=ss.split(';')
print(a1)
g = []
a3 = map(lambda x:g.extend(x.split('.')),a1)
f= []
print(g)
a4 = map(lambda x:f.extend(x.split(':')),g)
print(list(a3),f)

result=mySplit(ss,';,|\t')
import re

a8=re.split(r'[,;.:|]+',ss)

guess_number()
